//
//  WebViewOfOtherViewController.m
//  FreeTravel
//
//  Created by 徐康 on 16/9/7.
//  Copyright © 2016年 KX. All rights reserved.
//

#import "WebViewOfOtherViewController.h"
#import "FreeTravelNetwork.h"
@interface WebViewOfOtherViewController ()<UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@end

@implementation WebViewOfOtherViewController
- (void)webViewDidFinishLoad:(UIWebView *)webView{
    
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('drains-app mGuideToAppBox')[0].style.display = 'none'"];
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('xd-list fix')[0].style.display = 'none'"];
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('xdetail-header')[0].style.display = 'none'"];
    [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.getElementsByClassName('head-userinfo fix')[0].style.display = 'none'"];
    
    [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('bssDetTit jscmd')[0].style.display = 'none'"];
    
    [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.getElementsByClassName('prb js_show_reply active')[0].style.display = 'none'"];
    
    [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.getElementsByClassName('clearfix')[0].style.display = 'none'"];
    [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.getElementsByClassName('qui-footerBasic')[0].style.display = 'none'"];
    [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.getElementsByClassName('qui-header')[0].style.display = 'none'"];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"sdfasadfas"] style:UIBarButtonItemStylePlain target:self action:@selector(goBack)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
    self.webView = [[UIWebView alloc]initWithFrame:self.view.bounds];
    _webView.delegate = self;
    
    [self.view addSubview:_webView];
    
    [self handleData];
    
}
- (void)handleData{
    [FreeTravelNetwork GET:[NSString stringWithFormat:@"http://open.qyer.com/qyer/footprint/poi_detail?client_id=qyer_ios&client_secret=cd254439208ab658ddf9&count=20&page=1&poi_id=%ld&screensize=640&track_app_channel=App%%2520Store&track_app_version=7.0.1&track_device_info=iPhone%%25205s&track_deviceid=E9CA001A-5603-4CA8-B2EA-2BE34F691AC6&track_os=ios%%25209.3.4&v=1",self.ID] andBody:nil andHeader:nil andResponse:ZWYJSON andSuccessBlock:^(id result) {
        
        
        self.url = [[result objectForKey:@"data"] objectForKey:@"qyerurl"];
        
        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.url]];
        
        [_webView loadRequest:request];
        
        
    } andFailureBlock:^(NSError *error) {
        
    }];
}
- (void)goBack{
    [self.navigationController popViewControllerAnimated:YES];
}- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
